package com.ruoyi.web.pgci.controller;

import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.web.pgci.service.DataAnalysisService;
import com.ruoyi.web.pgci.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author joy
 * @create 2023-11-12 22:55
 * @description
 */
@Api("数据分析接口")
@RestController
@RequestMapping("dataAnalysis")
public class PgciDataAnalysisController {

    @Autowired
    private DataAnalysisService dataAnalysisService;

    @ApiOperation("统计数据概览（最上面一排）")
    @GetMapping("/getStatisticalSummary")
    public R<StatisticalSummary> getStatisticalSummary() {
        return R.ok(dataAnalysisService.getStatisticalSummary());
    }

    /**
     * Training distribution
     * @return
     */
    @ApiOperation("Training distribution")
    @GetMapping("/getTrainingDistribution")
    public R<TrainingDistributionVo> getTrainingDistribution(){
        return R.ok(dataAnalysisService.getTrainingDistribution());
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "postName", value = "岗位名称", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "learnReq", value = "学习要求（1 强制 0 推荐）", dataType = "Integer", dataTypeClass = Integer.class),
    })
    @ApiOperation("根据岗位名称获取岗位所对应的培训课，Training distribution 柱状图点击弹出课程详情")
    @GetMapping("/getTrainingDistributionCourses")
    public R<List<TrainingDistributionCourseVo>> getTrainingDistributionCourses(@RequestParam("postName") String postName, @RequestParam("learnReq") int learnReq) {
         return dataAnalysisService.getTrainingDistributionCourses(postName,learnReq);
    }

    @GetMapping("/getTrainingPlan")
    @ApiOperation("TrainingPlan 折线图")
    public R<TrainingPlanVo> getTrainingPlan(){
        return R.ok(dataAnalysisService.getTrainingPlan());
    }

    @GetMapping("/getOccupancy")
    @ApiOperation("Occupancy 使用仪表盘展示 （强制课程数/总课程数）")
    public R<Double> getOccupancy(){
         return R.ok(dataAnalysisService.getOccupancy());
    }

    @GetMapping("/getMandatoryAndRecommendedRate")
    @ApiOperation("饼图 （强制性课程 和 建议课程） ")
    public R<List<MandatoryAndRecommendedRateVo>> getMandatoryAndRecommendedRate(){
         return R.ok(dataAnalysisService.getMandatoryAndRecommendedRate());
    }
    @GetMapping("/getAnalysisOfTrainingCompletion")
    @ApiOperation("Analysis Of TrainingCompletion (堆叠柱状图)")
    public R<TrainingDistributionVo> getAnalysisOfTrainingCompletion(){
        return R.ok(dataAnalysisService.getAnalysisOfTrainingCompletion());
    }

    @GetMapping("/getAnnualTrainingAnalysis")
    @ApiOperation("Annual training analysis (折线图)")
    public R<EchartsLineVo> getAnnualTrainingAnalysis(){
        EchartsLineVo annualTrainingAnalysis = dataAnalysisService.getAnnualTrainingAnalysis();
       return R.ok(annualTrainingAnalysis);
    }

}
